package cn.ultrarisk.scadmin.manager.biz.monitor.entity;

import cn.ultrarisk.scadmin.manager.biz.solr.context.SolrState;
import cn.ultrarisk.scadmin.manager.biz.solr.entity.SolrReplica;
import cn.ultrarisk.mybatis.extension.annotation.Table;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * solr集合副本监控实体类
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/4/14
 * @since V1.0
 */
@Table(table = "solr_replica_monitor", idColumn = SolrReplicaMonitor.ID, autoIncrement = true)
public class SolrReplicaMonitor implements Serializable {
    private static final long serialVersionUID = -3035662840214782496L;

    public final static String ID = "id";
    public final static String NODE_ID = "node_id";
    public final static String COLLECTION_ID = "collection_id";
    public final static String SHARD_ID = "shard_id";
    public final static String REPLICA_ID = "replica_id";
    public final static String STATE = "state";
    public final static String NUM_DOCS = "num_docs";
    public final static String MAX_DOCS = "max_docs";
    public final static String DELETED_DOCS = "deleted_docs";
    public final static String SEGMENT_COUNT = "segment_count";
    public final static String INDEX_HEAP_USAGE = "index_heap_usage";
    public final static String INDEX_SIZE = "index_size";
    public final static String CREATE_TIME = "create_time";

    public static final Map<String, String> COLUMN_PROPERTY_MAP = new LinkedHashMap<String, String>();

    static {
        COLUMN_PROPERTY_MAP.put(ID, "id");
        COLUMN_PROPERTY_MAP.put(NODE_ID, "nodeId");
        COLUMN_PROPERTY_MAP.put(COLLECTION_ID, "collectionId");
        COLUMN_PROPERTY_MAP.put(SHARD_ID, "shardId");
        COLUMN_PROPERTY_MAP.put(REPLICA_ID, "replicaId");
        COLUMN_PROPERTY_MAP.put(STATE, "state");
        COLUMN_PROPERTY_MAP.put(NUM_DOCS, "numDocs");
        COLUMN_PROPERTY_MAP.put(MAX_DOCS, "maxDocs");
        COLUMN_PROPERTY_MAP.put(DELETED_DOCS, "deletedDocs");
        COLUMN_PROPERTY_MAP.put(SEGMENT_COUNT, "segmentCount");
        COLUMN_PROPERTY_MAP.put(INDEX_HEAP_USAGE, "indexHeapUsage");
        COLUMN_PROPERTY_MAP.put(INDEX_SIZE, "indexSize");
        COLUMN_PROPERTY_MAP.put(CREATE_TIME, "createTime");
    }

    /**
     * id
     */
    private Long id;
    /**
     * 节点id
     */
    private Integer nodeId;
    /**
     * 集合id
     */
    private Integer collectionId;
    /**
     * 分片id
     */
    private Integer shardId;
    /**
     * 副本id
     */
    private Integer replicaId;
    /**
     * 状态
     */
    private SolrState state;
    /**
     * 文档数
     */
    private Long numDocs;
    /**
     * 最大文档数
     */
    private Long maxDocs;
    /**
     * 已删除文档数
     */
    private Long deletedDocs;
    /**
     * 段数量
     */
    private Integer segmentCount;
    /**
     * 索引内存使用量
     */
    private Long indexHeapUsage;
    /**
     * 索引大小
     */
    private Long indexSize;
    /**
     * 创建时间
     */
    private Long createTime;

    public SolrReplicaMonitor() {
    }

    public SolrReplicaMonitor(SolrReplica replica, SolrState state) {
        this.nodeId = replica.getNodeId();
        this.collectionId = replica.getCollectionId();
        this.shardId = replica.getShardId();
        this.replicaId = replica.getId();
        this.state = state;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getNodeId() {
        return nodeId;
    }

    public void setNodeId(Integer nodeId) {
        this.nodeId = nodeId;
    }

    public Integer getCollectionId() {
        return collectionId;
    }

    public void setCollectionId(Integer collectionId) {
        this.collectionId = collectionId;
    }

    public Integer getShardId() {
        return shardId;
    }

    public void setShardId(Integer shardId) {
        this.shardId = shardId;
    }

    public Integer getReplicaId() {
        return replicaId;
    }

    public void setReplicaId(Integer replicaId) {
        this.replicaId = replicaId;
    }

    public SolrState getState() {
        return state;
    }

    public void setState(SolrState state) {
        this.state = state;
    }

    public Long getNumDocs() {
        return numDocs;
    }

    public void setNumDocs(Long numDocs) {
        this.numDocs = numDocs;
    }

    public Long getMaxDocs() {
        return maxDocs;
    }

    public void setMaxDocs(Long maxDocs) {
        this.maxDocs = maxDocs;
    }

    public Long getDeletedDocs() {
        return deletedDocs;
    }

    public void setDeletedDocs(Long deletedDocs) {
        this.deletedDocs = deletedDocs;
    }

    public Integer getSegmentCount() {
        return segmentCount;
    }

    public void setSegmentCount(Integer segmentCount) {
        this.segmentCount = segmentCount;
    }

    public Long getIndexHeapUsage() {
        return indexHeapUsage;
    }

    public void setIndexHeapUsage(Long indexHeapUsage) {
        this.indexHeapUsage = indexHeapUsage;
    }

    public Long getIndexSize() {
        return indexSize;
    }

    public void setIndexSize(Long indexSize) {
        this.indexSize = indexSize;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

}